package com.webtest.demo;

import static org.testng.Assert.assertTrue;


import org.testng.annotations.Test;

import com.webtest.core.BaseTest;



public class Admin_Login  extends BaseTest{
/*
 * 前端，共42个	
 */
	
	
	/*
	@Test 
	public void qdOpen() {
		webtest.open("");
		assertTrue(webtest.isTextPresent("登录"));
		
	}
	
	

	@Test(dependsOnMethods="qdOpen")
	public void testSunglass() {
		webtest.click("partLink=太阳镜");
	}
	
	@Test(dependsOnMethods="qdOpen")
	public void testWomen() {
		webtest.click("partLink=女士");
	}
//	3
	
//	@Test(dependsOnMethods="testLiuxing")
//	public void testLiuxing2() {
//		webtest.click("partLink=DANJIESHI2015夏季新款男士短袖T恤 男 韩版休闲修身V领透气半袖T恤衫");
//}
//	@Test(dependsOnMethods="testWomen")
//	public void testWomen1(){
//		webtest.click("partLink=本千2015夏棉麻短袖t恤 女套装民族风宽松大码两件套长裙亚麻女装");
//	}
	@Test(dependsOnMethods="testWomen")
	public void testWomen2(){
		webtest.click("partLink=销量");
	}	
	@Test(dependsOnMethods="testWomen")
	public void testWomen3(){
		webtest.click("partLink=价格");
	}
	@Test(dependsOnMethods="testWomen")
	public void testWomen4(){
		webtest.click("partLink=评论数");
	}
	@Test(dependsOnMethods="testWomen")
	public void testWomen5(){
		webtest.click("partLink=时间");
		assertTrue(webtest.isTextPresent("2015夏装女装新款短袖淑女款裙子"));
	}
	@Test(dependsOnMethods="testWomen")
	public void testWomen6AboutBrand(){
		webtest.click("partLink=吉芬");
		assertTrue(webtest.isTextPresent("2015夏装女装新款短袖淑女款裙子"));
	}
	
	@Test(dependsOnMethods="testWomen")
	public void testWomenXiabiao(){
		webtest.click("link=2");
	}
	@Test(dependsOnMethods="testWomen")
	public void testWomen5to1(){
		webtest.click("partLink=2015夏装女装新款短袖淑女款裙子");
	}
	@Test(dependsOnMethods="testWomen5")
	public void testWomen5to2(){
		webtest.click("partLink=半身裙");
	}
	@Test(dependsOnMethods="testWomen5")
	public void testWomen5to3(){
		webtest.click("partLink=情侣装");
	}
	@Test(dependsOnMethods="testWomen5")
	public void testGoBack(){
		webtest.goBack();
	}
	@Test(dependsOnMethods="qdOpen")
	public void testLiuxing() {
		webtest.click("partLink=流行");
	}
	@Test(dependsOnMethods="qdOpen")
	public void testDaoHang() {
		webtest.click("link=蕾丝连衣裙");
	}
	@Test(dependsOnMethods="qdOpen")
	public void testDaoHang2() {
		webtest.click("link=孕妇装");
	}
	
	@Test(dependsOnMethods="qdOpen")
	public void testGtMore() {
		webtest.click("link=换一批");
	}
	@Test(dependsOnMethods="qdOpen")
	public void testDiaodai() {
		webtest.click("link=宽松T恤");
		assertTrue(webtest.isTextPresent("本千2015夏棉麻短袖t恤 女套装民族风宽松大码两件套长裙亚麻女装"));
//		本千2015夏棉麻短袖t恤 女套装民族风宽松大码两件套长裙亚麻女装
	}
	@Test(dependsOnMethods="testDiaodai")
	public void testDiaodai2() {
		webtest.click("link=本千2015夏棉麻短袖t恤 女套装民族风宽松大码两件套长裙亚麻女装");
	}
	@Test(dependsOnMethods="testDiaodai2")
	public void testDiaodai2New() {
		webtest.click("link=女士");
	}
	@Test(dependsOnMethods="testDiaodai2New")
	public void testDiaodai2Return() {
		webtest.goBack();
	}
	@Test(dependsOnMethods="testWomen")
	public void testCuxiao(){
		webtest.click("partLink=华南夏日");
	}
	@Test(dependsOnMethods="qdOpen")
	public void testMom() {
		webtest.click("partLink=妈妈装");
	}
	@Test(dependsOnMethods="qdOpen")
	public void testMen() {
		webtest.click("partLink=");
	}
	@Test(dependsOnMethods="qdOpen")
	public void testBottom() {
		webtest.click("partLink=百度");
	}
	@Test(dependsOnMethods="qdOpen")
	public void testBottom2() {
		webtest.click("partLink=木木设计");
	}
	@Test(dependsOnMethods="qdOpen")
	public void test2() {
		webtest.click("partLink=旗袍");
	}
	@Test(dependsOnMethods="qdOpen")
	public void testInput(){
//		<input type="text" name="keyword" value="">
		webtest.type("xpath=//input[@type='text']", "半身裙");
//		<button type="submit">搜索</button>
		webtest.click("xpath=//button[@type='submit']");
	}
	@Test(dependsOnMethods="testInput")
	public void testBackToHomePicture() {
		webtest.click("id=logo");
	}
	@Test(dependsOnMethods="qdOpen")
	public void testLogin() {
		webtest.click("link=请登录");	
	}
	@Test(dependsOnMethods="testLogin")
	public void testQDLogin1() {
		webtest.click("class=right-link");
		webtest.type("xpath=//input[@name='username']", "adminn");
		webtest.type("xpath=//input[@name='password']", "adminn");
		webtest.type("xpath=//input[@name='password2']", "adminn");
		webtest.type("name=email", "123@qq.com");
		webtest.click("xpath=//input[@type='submit']");
	}
	@Test(dependsOnMethods="qdOpen")
	public void testQDLogin2() {
		webtest.click("link=快速注册");
		webtest.type("xpath=//input[@name='username']", "adminnn");
		webtest.type("xpath=//input[@name='password']", "adminnn");
		webtest.type("xpath=//input[@name='password2']", "adminnn");
		webtest.type("name=email", "1234@qq.com");
		webtest.click("xpath=//input[@type='submit']");
	}
	@Test(dependsOnMethods="testLogin")
	public void testSignUp() {
		webtest.type("xpath=//input[@name='username']", "adminn");
		webtest.type("xpath=//input[@name='username']", "adminn");
		webtest.click("xpath=//input[@type='submit']");
	}
	@Test(dependsOnMethods="testLogin")
	public void testSignUpA() {
		webtest.click("link=京东钱包");
	}
	@Test(dependsOnMethods="testLogin")
	public void testSignUpB() {
		webtest.click("link=QQ");
	}
	@Test(dependsOnMethods="testLogin")
	public void testSignUpC() {
		webtest.click("link=微信");
	}
	@Test(dependsOnMethods="testLogin")
	public void testLoginBack() {
		webtest.goBack();
	}
	
	
	
	/*
	 * 后端
	 */
	@Test 
	public void hdOpen() {
		webtest.open("admin.php/Login/index.html");
		webtest.type("name=name", "admin");
		webtest.type("name=password", "123456");
		webtest.click("xpath=//button[@type='submit']");
		assertTrue(webtest.isTextPresent("退出"));	
	}
	@Test(dependsOnMethods="hdOpen")
	public void testButton1() {
		webtest.click("xpath=//button[@class='btn btn-success']");
	}
	@Test(dependsOnMethods="hdOpen")
	public void testButton2() {
		webtest.click("xpath=//button[@class='btn btn-info']");
	}
	@Test(dependsOnMethods="hdOpen")
	public void testButton3() {
		webtest.click("xpath=//button[@class='btn btn-warning']");
	}
	@Test(dependsOnMethods="hdOpen")
	public void testButton4() {
		webtest.click("xpath=//button[@class='btn btn-danger']");
	}
	@Test(dependsOnMethods="hdOpen")
	public void testStaff() {
		webtest.click("partLink=员工管理");
	}
	@Test(dependsOnMethods="testStaff")
	public void testStaffXiabiao() {
		webtest.click("link=4");
	}
	@Test(dependsOnMethods="testStaff")
	public void testStaffSearch() {
		webtest.type("class=username_search","admin");
		webtest.click("xpath=//button[@class='btn btn-purple btn-sm']");
		assertTrue(webtest.isTextPresent("张三"));
	}
	@Test(dependsOnMethods="testStaffSearch")
	public void testStaffEdit() {
		webtest.click("partLink=编辑");
	}
	
	@Test(dependsOnMethods="testStaffSearch")
	public void testStaffEdit1() {
		webtest.type("id=address","罗翔老师隔壁");
		webtest.click("xpath=//button[@type='submit']");
	}
	@Test(dependsOnMethods="testStaffEdit1")
	public void testStaffEditIsOk() {
		webtest.click("partLink=编辑");
		if(webtest.isTextPresent("罗翔老师隔壁")) {
			System.out.println("张三同志搬家去了罗翔老师隔壁");
		}else {
			System.out.println("张三同志没搬去罗翔老师隔壁");
		}
	}
	
	@Test(dependsOnMethods="hdOpen")
	public void testComment() {
		webtest.click("partLink=评论管理");
	}
	@Test(dependsOnMethods="testComment")
	public void testComment2() {
		webtest.click("partLink=评论列表");
	}
	
	

	
	
	
	


}
